#include "LinkQueue.h"
#include "LinkStack.h"
#include <stdio.h>
#define true 1
#define false 0
typedef struct QueueStack
{
    LQueue queue1;
    LQueue queue2;
}QueueStack;
int  InitQueueStack(QueueStack *s)
{
    InitLQueue(&s->queue1);
    InitLQueue(&s->queue2);
    return true;
}
void QueueStackPush(QueueStack *s,ElementType element)
{
    if(s->queue1.queue.len==0)
    {
        QPush(&s->queue2,element);
    }
    else
    {
        QPush(&s->queue1,element);
    }
}
int IsQueueStackEmpty(QueueStack *s)
{
    if(s->queue1.queue.len==0&&s->queue2.queue.len==0)
        return true;

    else
        return false;
}
ElementType *QueueStackPop(QueueStack *s)
{
    if(IsQueueStackEmpty(s)==true)
    {
        printf("stack is empty\n");
        return NULL;
    }
    if(s->queue1.queue.len==0)
    {
        while(s->queue2.queue.len>1)
        {
            QPush(&s->queue1,*QPop(&s->queue2));
        }
        return QPop(&s->queue2);
    }
    else 
    {
        while(s->queue1.queue.len>1)
        {
            QPush(&s->queue2,*QPop(&s->queue1));
        }
        return QPop(&s->queue1);
    }
}
void main()
{
    QueueStack s;
    InitQueueStack(&s);
    for(int i=0;i<10;i++)
    {
        QueueStackPush(&s,i+1);
    }
    while(IsQueueStackEmpty(&s)==false)
    {
        printf("%d ",*QueueStackPop(&s));
    }
    printf("\n");
}